package com.major.dawn.leetCode.string;

public class SortStringUntil {

    public static void insertSort(char[] chars) {

        int length = chars.length;

        for (int i = 1; i < length ; i++) {

            for (int j = 0; j < i; j++) {
                if (chars[i] < chars[j]) {
                    swap(chars, i, j);
                    break;
                }
            }
        }


    }


    public static void swap(char[] chars, int i, int j) {
        char aChar = chars[i];

        System.arraycopy(chars, j, chars, j + 1, i - j);
        chars[j] = aChar;
    }

    //    冒泡排序
    public static void bubbleSorting(char[] chars) {

    }

    public static void main(String[] args) {
        char[] chars = new char[]{'c', 'f', 'a', 'd'};
        System.out.println(chars);
        insertSort(chars);
        System.out.println(chars);
    }
}
